package util;

import java.io.UnsupportedEncodingException;

public class OSCheckAndConvert {
    private final static String OS = System.getProperty("os.name").toLowerCase();
    /**
     * Check the current system is windows or not?
     * @return true/false for yes/no
     */
    private static boolean isWindowsOS(){
        return OS.contains("windows") ? true : false;
    }

    /**
     * if OS is windows transform url address into windows format  eg.: "Program20%Files" to "Program Files"
     * @param input string that need to be transform
     * @return edited string
     */
    public static String stringConvert(String input) {
        if(!isWindowsOS()) return input;
        try {
            input = java.net.URLDecoder.decode(input,"utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return  input;
    }
}
